package com.cqjtu.drive.controller;

import com.cqjtu.drive.pojo.Coach;
import com.cqjtu.drive.response.Response;
import com.cqjtu.drive.service.CoachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PreDestroy;
import java.util.List;

/**
 * @Author zxl
 * @Date 2024/6/14 9:25
 */

@RestController
public class CoachController {
    @Autowired
    CoachService coachService;

    @PostMapping("/api/coach/update")
    public Response<String> updateCoach(@RequestBody Coach coach) {
        return coachService.updateCoach(coach);
    }
     @PostMapping("/api/coach/getCoachByUserId")
    public Response<Coach>getCoachByUserId(@RequestParam String userId){return coachService.getCoachByUserId(userId);}
    @PostMapping("/api/coach/delete")
    public Response<String> deleteCoach(@RequestParam String cId) {
        return coachService.deleteCoach(cId);
    }

    @PostMapping("/api/coach/getallData")
    public Response<List<Coach>> getall() {
        return coachService.getAllCoaches();
    }

    @PostMapping("/api/coach/getByname")
    public Response<List<Coach>> getByname(@RequestParam String cName) {
        return coachService.getCoachesByName(cName);
    }

    @PostMapping("/api/coach/insert")
    public Response<String> insertOne(@RequestBody Coach coach){
        return coachService.insertCoach(coach);
    }
}
